var az = {
	htmldtype:"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",
	html5dtype:"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">",
	xmldtype:"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
	setDoctype:function(docType){
		document.doctype=docType;
	},
	browserDetect:{
			browser:function(){return this.searchString(this.dataBrowser)||"An unknown browser";},
			version:function(){return this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";},
			OS:function(){return this.searchString(this.dataOS) || "an unknown OS";},
			searchString: function (data) {
				for (var i=0;i<data.length;i++)	{
					var dataString = data[i].string;
					var dataProp = data[i].prop;
					this.versionSearchString = data[i].versionSearch || data[i].identity;
					if (dataString) {
						if (dataString.indexOf(data[i].subString) != -1)
							return data[i].identity;
					}
					else if (dataProp)
						return data[i].identity;
				}
			},
			searchVersion: function (dataString) {
				var index = dataString.indexOf(this.versionSearchString);
				if (index == -1) return;
				return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
			},
			dataBrowser: [
				{
					string: navigator.userAgent,
					subString: "Chrome",
					identity: "Chrome"
				},
				{ 	string: navigator.userAgent,
					subString: "OmniWeb",
					versionSearch: "OmniWeb/",
					identity: "OmniWeb"
				},
				{
					string: navigator.vendor,
					subString: "Apple",
					identity: "Safari",
					versionSearch: "Version"
				},
				{
					prop: window.opera,
					identity: "Opera",
					versionSearch: "Version"
				},
				{
					string: navigator.vendor,
					subString: "iCab",
					identity: "iCab"
				},
				{
					string: navigator.vendor,
					subString: "KDE",
					identity: "Konqueror"
				},
				{
					string: navigator.userAgent,
					subString: "Firefox",
					identity: "Firefox"
				},
				{
					string: navigator.vendor,
					subString: "Camino",
					identity: "Camino"
				},
				{		// for newer Netscapes (6+)
					string: navigator.userAgent,
					subString: "Netscape",
					identity: "Netscape"
				},
				{
					string: navigator.userAgent,
					subString: "MSIE",
					identity: "Explorer",
					versionSearch: "MSIE"
				},
				{
					string: navigator.userAgent,
					subString: "Gecko",
					identity: "Mozilla",
					versionSearch: "rv"
				},
				{ 		// for older Netscapes (4-)
					string: navigator.userAgent,
					subString: "Mozilla",
					identity: "Netscape",
					versionSearch: "Mozilla"
				}
			],
			dataOS : [
				{
					string: navigator.platform,
					subString: "Win",
					identity: "Windows"
				},
				{
					string: navigator.platform,
					subString: "Mac",
					identity: "Mac"
				},
				{
					   string: navigator.userAgent,
					   subString: "iPhone",
					   identity: "iPhone/iPod"
			    },
				{
					string: navigator.platform,
					subString: "Linux",
					identity: "Linux"
				}
			]

		}, // end detect browser
	util:{
		isArray:function(v){return typeof(v)=='object' && v instanceof Array;},
		isObject:function(o){return typeof(o)=='object';},
		isString:function(s){return typeof(s)=='string';},
		tolowercase:function(s){return s.toLowerCase();},
		indexOfObject:function(array,object){
			for(var index in array ){
				var helper = false ;
				for( var key in array[index] ){
					if ( array[index][key] == object[key] ){
						helper=true;
					}
				}
				if ( helper ) return index ;
			}
			return -1;
		},
		indexOf:function(array,element){
			for(var index in array ){
				if ( array[index] == element ) return index ;
			}
			return -1;
		},
		removeArrayElement:function(array,index){
			var temp = new Array();
			for( var i in array ){
				if ( i != index ){
					temp.push( array[i] );
				}
			}
			return temp;
		},
		addArrayFirst:function(array,arrayElement){
			var temp = new Array();
			temp.push(arrayElement);
			for( var i in array ){
				temp.push( array[i] );
			}
			return temp;
		},
		addArrayLast:function(array,arrayElement){
			var temp = new Array();
			for( var i in array ){
				temp.push( array[i] );
			}
			temp.push(arrayElement);
			return temp;
		},
		addArrayAt:function(array,arrayElement,index){
			var temp = new Array();
			for( var i in array ){
				if ( i == index ){
					temp.push(arrayElement);
					temp.push( array[i] );
				}
				else{
					temp.push( array[i] );
				}
			}
			temp.push(arrayElement);
			return temp;
		},
		strcmp:function(str1,str2){
			return str1.localeCompare(str2);
		},
		element:function(v){
			if ( v.charAt(0) == "." ){
				v = v.replace(".","");
				var allT=document.getElementsByTagName('*'), allCN=[], i=0, a;
				while(a=allT[i++]){
					if ( a.attributes["class"] != null && a.attributes["class"].nodeValue != "" ){
						var _class = a.attributes["class"].nodeValue.split(" ");
						var index = az.util.indexOf(_class,v);
						index!=-1?allCN[allCN.length]=a:null;
					}
				}
				return allCN ;
			}else if( v.charAt(0) == "#" ){
				return document.getElementById(v.replace("#",""));
			}else{
				var allT=document.getElementsByTagName(v), allTN=[], i=0, a;
				while(a=allT[i++]){
					if ( a.tagName != null && a.tagName != "" ){
						az.util.tolowercase(a.tagName)==az.util.tolowercase(v)?allTN[allTN.length]=a:null;
					}
				}
				return allTN ;
			}
		}
	},// the end of util
	ajax:function(request){
		var xmlhttp;
		/*
		{
			url:"",
			method:"",
			data:"",
			success:function(result){}
		}
		*/
		var params = "" ;
		if(az.util.isObject(request.data)){
			params = new Array() ;
			for( var key in request.data ){
				params.push(key + "=" + request.data[key] );
			}
			params = params.join("&");
		}
		
		
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
		else{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		if ( request.method == "GET" ){
			xmlhttp.open("GET",request.url,true);
			xmlhttp.send(params);
		}
		else if ( request.method == "POST" ){
			xmlhttp.open("POST",request.url,true);
			xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			xmlhttp.send(params);
		}
		
		// this function create an Array that contains the JS code of every <script> tag in parameter
		// then apply the eval() to execute the code in every script collected
		xmlhttp.parseScript=function(strcode) {
		  var scripts = new Array();         // Array which will store the script's code
		  
		  // Strip out tags
		  while(strcode.indexOf("<script") > -1 || strcode.indexOf("</script") > -1) {
		    var s = strcode.indexOf("<script");
		    var s_e = strcode.indexOf(">", s);
		    var e = strcode.indexOf("</script", s);
		    var e_e = strcode.indexOf(">", e);
		    
		    // Add to scripts array
		    scripts.push(strcode.substring(s_e+1, e));
		    // Strip from strcode
		    strcode = strcode.substring(0, s) + strcode.substring(e_e+1);
		  }
		  
		  // Loop through every script collected and eval it
		  for(var i=0; i<scripts.length; i++) {
		    try {
		      eval(scripts[i]);
		    }
		    catch(ex) {
		      // do what you want here when a script fails
		    }
		  }
		}
		
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				var strcode = xmlhttp.response ;
				this.parseScript(strcode);
				request.success(strcode);
			}
		};
	},
	control:function(o){
		var objects = null ;
		if ( window.document===o){
			o.load=false;
			o.callback!==undefined?true:o.callback=new Array();
			o.ready=function(callback){
				callback!==false&&callback!==undefined&&callback!==""?this.callback.push(callback):false;
				this.onreadystatechange=function(){
					if(this.load){for(var i in this.callback ){this.callback[i]();}}
					else{o.load=true;}
				};
			};
			return o ;
		}
		else if(az.util.isObject(o)){			
			return o!==null?az.view.html.funcs(o):null;
		}
		else if(az.util.isString(o)){
			objects = az.util.element(o);
			if ( az.util.isArray(objects) ){
				var clas = new Array(); 
				for( var index in objects ){
					if ( objects[index]!==null ) clas[index]=az.view.html.funcs( objects[index]);
				}
				return clas;
			}else{
				return objects!==null?az.view.html.funcs( objects ):null;
			}
		}
	},// the end of control
	view:{
		html:{
			funcs:function(elems){
				elems.change=function(callback){elems.onchange=function(){callback();};};
				elems.click=function(callback){elems.onclick=function(){callback();};};
				elems.over=function(callback){elems.onmouseover=function(){callback();};};
				elems.out=function(callback){elems.onmouseout=function(){callback();};};
				elems.down=function(callback){elems.onmousedown=function(){callback();};};
				elems.up=function(callback){elems.onmouseup=function(){callback();};};
				elems.getfocus=function(callback){elems.onfocus=function(){callback();};};
				elems.setFocus=function(){elems.focus();};
				elems.keyup=function(callback){elems.onkeyup=function(e){callback(e);};};
				elems.keydown=function(callback){elems.onkeydown=function(e){callback(e);};};
				elems.keypress=function(callback){elems.onkeypress=function(e){callback(e);};};
				elems.html=function(a){$(elems).html(a);};
				elems.append=function(o){if(az.util.isObject(o))elems.appendChild(o);else elems.html(o);};
				elems.getAttr = function( name ){ 
					if ( az.browserDetect.browser() == "Explorer" ){
						if ( az.browserDetect.version() >= 9 ){
							return elems.getAttribute(name);
						}else{
							return elems.attributes.item(name)!=null?elems.attributes.item(name).nodeValue:false;
						}
					}else if( az.browserDetect.browser() == "Chrome" ){
						return elems.getAttribute(name);
					}
					else if( az.browserDetect.browser() == "Firefox" ){
						return elems.getAttribute(name);
					}
					
				};
				elems.setAttr = function( name , value ){
					if ( az.browserDetect.browser() == "Explorer" ){
						if ( az.browserDetect.version() >= 8 ){
							elems.setAttribute(name,value);
						}else{
							if ( name != "style" ){
								if ( elems.attributes[name] != null){
									elems.attributes[name].nodeValue=value;
								}else{
									var attr = document.createAttribute(name);
									attr.nodeValue=value;
									elems[name]=value;
								}
							}
						}
					}else if( az.browserDetect.browser() == "Chrome" ){
						elems.setAttribute(name,value);
					}
					else if( az.browserDetect.browser() == "Firefox" ){
						elems.setAttribute(name,value);
					}
				};
				elems.removeAttr=function( name ){elems.removeAttribute(name);};
				elems.enable=function(enable){
					if ( enable ){
						elems.setAttr("disabled",!enable);
						elems.style.border="1px solid #666";
						elems.style.color="#666";
					}
					else{
						elems.setAttr("disabled",!enable);
						elems.style.border="1px solid #F1F2F3";
						elems.style.color="#F1F2F3";
					}
				};
				///////////
				elems.existClass = function(_class){
					if(elems.getAttr("class")!=null){
						var elements = $(elems).attr("class").split(" ") ;
						var index = elements.indexOf(_class);
						if(index!=-1)return true ;
					}
					return false ;
				};
				elems.addClass = function(_class){
					$(elems).addClass(_class);
				};
				elems.removeClass = function(_class){
					$(elems).removeClass(_class);
				};
				return elems;
			}, // end of funcs
			element:function(tag,attrs){
				if ( !az.util.isString(tag) )return null ;
				var _e=az.view.html.funcs(document.createElement(tag));
				for( var index in attrs ){
					for(var key in attrs[index]) {
						$(_e).attr(key,attrs[index][key]);
					}
				}
				return _e ;
			},// end of view element
			input:function(attrs){
				var _e = az.view.html.element("input",attrs);
				if ( _e.getAttr("type")=="submit" || _e.getAttr("type")=="button" ){
					_e.getAttr("class")==null?_e.addClass("button_empty"):false;
				}else{
					_e.getAttr("class")==null?_e.addClass("az_input_box"):false;
				}
				return _e;
			}, // end input
			img:function(attrs){
				var _e = az.view.html.element("img",attrs);
				return _e;
			}, // end img
			a:function(o,attrs){
				var _e = az.view.html.element("a",attrs);
				_e.getAttr("class")==null?_e.addClass("az_anchor"):"";
				if ( az.util.isObject(o)){
					_e.append(o);
				}
				else if ( az.util.isString(o)){
					_e.html(o);
				}
				return _e;
			}, // end of a
			label:function(o,attrs){
				var _e = az.view.html.element("label",attrs);
				_e.getAttr("class")==null?_e.addClass("az_label"):"";
				if ( az.util.isObject(o)){
					_e.append(o);
				}
				else if ( az.util.isString(o)){
					_e.html(o);
				}
				return _e;
			}, // end of label
			div:function(o,attrs){
				var _e = az.view.html.element("div",attrs);
				if ( az.util.isObject(o)){
					_e.append(o);
				}
				else if ( az.util.isString(o)){
					_e.html(o);
				}
				return _e;
			}, // end of div
			span:function(o,attrs){
				var _e = az.view.html.element("span",attrs);
				if ( az.util.isObject(o)){
					_e.append(o);
				}
				else if ( az.util.isString(o)){
					_e.html(o);
				}
				return _e;
			}, // end of span
			list:function(items,attrs){
				var _e = az.view.html.element("ul",attrs);
				for(var key in items) {
					var li = az.view.html.li(items[key],[{value:key}]);
					_e.append(li);
				}
				return _e;
			},
			li:function(o,attrs){
				var _e = az.view.html.element("li",attrs);
				if ( az.util.isObject(o)){
					_e.append(o);
				}
				else if ( az.util.isString(o)){
					_e.html(o);
				}
				return _e;
			}, // end li
			dropdown:function(items,_default,attrs){
				var _e = az.view.html.element("select",attrs);
				var op = az.view.html.element("option",[{value:"-1"}]);
				op.html(_default);
				_e.append(op);
				for(var key in items) {
					var op = az.view.html.element("option",[{value:key}]);
					op.html(items[key]);
					_e.append(op);
				}
				return _e;
			}, //  end dropdown
			td:function(o,attrs){
				var _e = az.view.html.element("td",attrs);
				if ( az.util.isObject(o)){
					_e.append(o);
				}
				else if ( az.util.isString(o)){
					_e.html(o);
				}
				else{
					_e.html(o);
				}
				return _e;
			},// end td
			tr:function(items,attrs){
				var _e = az.view.html.element("tr",attrs);
				if(az.util.isArray(items)){
					for(var index in items ){
						if(az.util.isString(items[index])){
							var _se = az.view.html.element("td");
							_se.html(items[index]);
							_e.append(_se);
						}
						else if ( az.util.isObject(items[index])){
							_e.append(items[index]);
						}
					}
				}
				return _e ;
			}, // end tr
			table:function(items,attrs){
				var _e = az.view.html.element("table",attrs);
				for( var index in items ){
					_e.append(items[index]);
				}
				return _e ;
			}, // end table
		}, // end of view html
		spliter:function(){
			var _mode = false ;
			var _move_start = false;
			var _move_left_top = false ;
			var _move_right_bottom = false;
			var _spliter = az.view.html.div("",[{"class":"spliter"}]);
			var _pane_left_top = az.view.html.div("",[{"class":"spliter_left_top"}]);
			var _pane_right_bottom = az.view.html.div("",[{"class":"spliter_right_bottom"}]);
			var _spliter_bar = az.view.html.div("",[{"class":"spliter_bar"}]);
			var spliter_width = 0 ;
			var spliter_height = 0 ;
			var spliter_v = 0 ;
			
			_spliter.append( _pane_left_top );
			_spliter.append( _spliter_bar );
			_spliter.append( _pane_right_bottom );
			
			_spliter.appendLeftTop=function(o){
				_pane_left_top.append(o);
			};
			
			_spliter.appendRightBottom=function(o){
				_pane_right_bottom.append(o);
			};
			
			_spliter.setMode=function(mode){
				_mode = mode!=true?false:mode;
			};
			
			_spliter.getMode=function(){return _mode;};
			
			resize=function(e){
				var mouseX = 0 , mouseY = 0 ;
				
				if(e.offsetX) {
					mouseX = e.offsetX;
					mouseY = e.offsetY;
				}
				else if(e.layerX) {
					mouseX = e.layerX;
					mouseY = e.layerY;
				}
				var str = "";
				if ( !_mode ){
					if ( _move_start ){
						if ( _move_left_top && !_move_right_bottom ){
							if ( _pane_left_top.getWidth() > 100 ){
								_pane_left_top.style.width = mouseX + "px" ;
								_pane_right_bottom.style.width = parseInt( spliter_width - _pane_left_top.getWidth() - spliter_v ) + "px" ;
								_pane_left_top.html( _pane_left_top.style.width );
								_pane_right_bottom.html( _pane_right_bottom.style.width );
							}
						}
						else if( !_move_left_top && _move_right_bottom ){
							if ( _pane_right_bottom.getWidth() > 100 ){
								_pane_right_bottom.style.width = parseInt( _pane_right_bottom.getWidth() - mouseX ) + "px" ;
								_pane_left_top.style.width = parseInt( spliter_width - _pane_right_bottom.getWidth() - spliter_v ) + "px" ;
								_pane_left_top.html( _pane_left_top.style.width );
								_pane_right_bottom.html( _pane_right_bottom.style.width );
							}
						}
					}
				}else{
					if ( _move_start ){
						if ( _move_left_top && !_move_right_bottom ){
							if ( _pane_left_top.getHeight() > 100 ){
								_pane_left_top.style.height = mouseY + "px" ;
								_pane_right_bottom.style.height = parseInt( spliter_height - _pane_left_top.getHeight() - spliter_v ) + "px" ;
								_pane_left_top.html( _pane_left_top.style.height );
								_pane_right_bottom.html( _pane_right_bottom.style.height );
							}
						}
						else if( !_move_left_top && _move_right_bottom ){
							if ( _pane_right_bottom.getHeight() > 100 ){
								_pane_right_bottom.style.height = parseInt( _pane_right_bottom.getHeight() - mouseY ) + "px" ;
								_pane_left_top.style.height = parseInt( spliter_height - _pane_right_bottom.getHeight() - spliter_v ) + "px" ;
								_pane_left_top.html( _pane_left_top.style.height );
								_pane_right_bottom.html( _pane_right_bottom.style.height );
							}
						}
					}
				}
			};
			
			_spliter_bar.down(function(e){
				_move_start=true;
			});
			
			_spliter_bar.up(function(e){
				_move_start=false;
			});
			
			_pane_left_top.move(function(e){
				_move_left_top = true ;
				_move_right_bottom = false ;
				resize(e);
			});
			
			_pane_left_top.up(function(e){
				_move_start=false;
			});
			
			_pane_right_bottom.move(function(e){
				_move_left_top = false ;
				_move_right_bottom = true ;
				resize(e);
			});
			
			_pane_right_bottom.up(function(e){
				_move_start=false;
			});
			
			_spliter.loadSpliter=function(){
				_spliter.setAttr("style","position: absolute;display: block;width: 100%;height: 100%;left: 0;top: 0;");
				spliter_width = _spliter.getWidth();
				spliter_height = _spliter.getHeight();
				alert( spliter_width + " : " + spliter_height );
				if ( !_mode ){
					spliter_v = spliter_width%2!=0?5:4;
					pane_width_height=spliter_width%2!=0?(spliter_width-spliter_v)/2:(spliter_width-spliter_v)/2;
					_pane_left_top.html( spliter_width + " : " + pane_width_height );
					_pane_left_top.setAttr("style","position: relative;display: block;float: left; width:"+ pane_width_height +"px; height: 100%; z-index:100; background: lime ;");
					_spliter_bar.setAttr( "style" , "position: relative;display: block;float: left;background: #EEE;cursor: pointer; width:"+ spliter_v +"px; height: 100%; box-shadow: 0px 0px 2px #999; z-index:101 ;" );
					_pane_right_bottom.setAttr("style","position: relative;display: block;float: left; width:"+ pane_width_height +"px; height: 100%; z-index:100; background: gray;");
				}
				else{
					spliter_v = spliter_height%2!=0?5:4;
					pane_width_height=spliter_height%2!=0?(spliter_height-spliter_v)/2:(spliter_height-spliter_v)/2;
					_pane_left_top.html( spliter_height + " : " + pane_width_height );
					_pane_left_top.setAttr("style","position: relative;display: block;float: left; width:100%; height: "+ pane_width_height +"px; z-index:100; background: lime ;");
					_spliter_bar.setAttr( "style" , "position: relative;display: block;float: left;background: #EEE;cursor: pointer; width: 100%; height:"+ spliter_v +"px; box-shadow: 0px 0px 2px #999; z-index:101 ;" );
					_pane_right_bottom.setAttr("style","position: relative;display: block;float: left; width: 100%; height: "+ pane_width_height +"px; z-index:100; background: gray;");
				}
			};
			
			return _spliter ;
		},
		htmlPopup:function(content,mode){
			var _callback = false;
			var _mode = mode&&mode!=undefined&&mode!=""?true:false; // _mode = false then content is html else is text plain
			var _content = "" ;
			var _holder = az.view.html.div("",[{"class":"html_popup_holder"},{"style":"position: fixed; display: block; left: 0; top: 0; width: 100%; height: 100%; z-index:9999; overflow: visible;"}]);
			var _overlay = az.view.html.div("",[{"class":"html_popup_overlay"},{"style":"position: fixed; display: block; left: 0; top: 0; width: 100%; height: 100%; background: rgba(221, 221, 221, 0.5); "}]);
			var _htmlPopup = az.view.html.div("",[{"class":"html_popup"},{"style":"overflow: hidden ;position: relative; display: none; float: none ; margin: 20px auto auto auto; width: 100%; "}]);
			var _closeButton = az.view.html.a("X",[{"class":"html_pupup_close"},{"style":"cursor: pointer ; position: absolute; display: none; left: 100%; top: -20px; width: 20px ; height: 20px; line-height: 20px; border: 1px solid #CCC; border-radius: 2px; background: #FFF; text-align: center ;"}]);
			var _contentLayout = az.view.html.div("",[{"class":"pop_content"},{"style":"overflow:hidden;"}]);
			
			_holder.setContent=function(content){
				content !== false ? (content === undefined? _content = (_mode?"<preg></preg>":"") : _content = _mode?"<preg>"+content+"</preg>":"" ) : false ;
				$("body").find(".html_popup_holder").remove();
				$("body").append(_holder);
				$(_htmlPopup).html(content);	
				var width = parseInt($(_holder).find(".popup_background").css("width").replace("px","")) + 10 ;
				$(_htmlPopup).css("width", width+"px");
				$(_htmlPopup).slideDown();
			}
			
			_holder.setMode=function(mode){
				_mode = mode ? true : false;
			}
			
			_overlay.click(function(){
				$(_holder).remove();
			});
			
			_closeButton.click(function(){
				$(_holder).remove();
			});
			
			$(_htmlPopup).append( _closeButton );
			$(_htmlPopup).append( _content );
			$(_holder).append(_overlay );
			$(_holder).append(_htmlPopup);
			
			_holder.close=function(callback){
				callback&&callback!=undefined&&callback!=""?_callback=callback:false;
				this.closeButton.click();
			};
			_holder.setMode(mode);
			_holder.setContent(content);
			return _holder;
		}
	}// the end of view
};
/*
function html(a){
	if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;
	if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!bf[($.exec(a)||["",""])[1].toLowerCase()]){
		a=a.replace(Z,"<$1></$2>");
		try{
			for(var c=0,d=this.length;c<d;c++)
				this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)
			}
		catch(e){
			this.empty().append(a)}
	}
	else 
		f.isFunction(a)
				?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))})
				:this.empty().append(a);
	return this
}
*/